<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: 47474
  Date: 2021/8/7
  Time: 16:38
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    pageContext.setAttribute("APP_PATH",request.getContextPath());
%>
<script type="text/javascript" src="${APP_PATH}/static/js/jquery-3.6.0.js"></script>
<link rel="stylesheet" type="text/css" href="${APP_PATH}/static/bootstrap-3.4.1-dist/css/bootstrap.min.css"/>
<script type="text/javascript" src="${APP_PATH}/static/bootstrap-3.4.1-dist/js/bootstrap.min.js"></script>

<html>
<head>
    <title>User List</title>
</head>
<body>

<div class="container">
    <div class="row">
        <div class="col-md-12">
            <h2>用户列表管理</h2>
        </div>
    </div>
    <div class="row">
        <div class="col-md-4 col-md-offset-8" style="margin-bottom: 20px">
            <button class="btn btn-primary">添加</button>
            <button class="btn btn-danger">删除</button>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-hover">
                <tr>
                    <th>#</th>
                    <th>昵称</th>
                    <th>密码</th>
                    <th>性别</th>
                    <th>年龄</th>
                    <th>邮箱</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${pageInfo.list}" var="user">
                    <tr>
                        <th>${user.userId}</th>
                        <th>${user.userName}</th>
                        <th>${user.userPassword}</th>
                        <th>${user.gender}</th>
                        <th>${user.age}</th>
                        <th>${user.email}</th>
                        <th>
                            <button class="btn btn-primary btn-sm">
                                <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>编辑</button>
                            <button class="btn btn-danger btn-sm">
                                <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>删除</button>
                        </th>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </div>

<%--    分页信息--%>
    <div class="row">
<%--        分页文字信息--%>
        <div class="col-md-4 col-xs-6">当前第${pageInfo.pageNum}页，共有${pageInfo.pages}页，共有${pageInfo.total}条记录</div>
<%--        分页条信息--%>
        <div class="col-md-8 col-xs-6">
            <nav aria-label="Page navigation">
                <ul class="pagination">

                    <c:if test="${pageInfo.hasPreviousPage}">
                        <li>
                            <a href="${APP_PATH}/user/list?pn=${pageInfo.pageNum-1}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <li>
                        <a href="${APP_PATH}/user/list?pn=1">首页</a>
                    </li>

                    <c:forEach items="${pageInfo.navigatepageNums}" var="pageNum">
                        <c:if test="${pageNum == pageInfo.pageNum}">
                            <li class="active"><a href="#">${pageNum}</a></li>
                        </c:if>
                        <c:if test="${pageNum != pageInfo.pageNum}">
                            <li><a href="${APP_PATH}/user/list?pn=${pageNum}">${pageNum}</a></li>
                        </c:if>
                    </c:forEach>
<%--                    有下一页就显示下一页--%>
                    <c:if test="${pageInfo.hasNextPage}">
                        <li>
                            <a href="${APP_PATH}/user/list?pn=${pageInfo.pageNum+1}" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <li>
                        <a href="${APP_PATH}/user/list?pn=${pageInfo.pages}">末页</a>
                    </li>
                </ul>
            </nav>
        </div>
    </div>
</div>


</body>
</html>
